import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_demo/pages/download/presentation/controllers/MapDataController.dart';

class DownloadSettingsView extends GetView<MapDataController> {
  const DownloadSettingsView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print('First rebuild');
    return Container(
        color: Colors.white,
        child: SafeArea(
            child: Column(children: [
          ElevatedButton(
            onPressed: () {
              Get.close();
            },
            child: const Text('返回'),
          ),
          ElevatedButton(
            onPressed: () {
              controller.stopMapDownloadTask();
            },
            child: const Text('Stop task'),
          ),
          Container(
            height: 50,
          ),
          ElevatedButton(
            onPressed: () {
              controller.puaseTask();
            },
            child: const Text('Pause task'),
          ),
          Container(
            height: 50,
          ),
          ElevatedButton(
            onPressed: () {
              controller.resumeTask();
            },
            child: const Text('Resume task'),
          ),
          Container(
            height: 50,
          ),
          ElevatedButton(
            onPressed: () {
              controller.startDownload(MapDownloadParams(
                  mapUrl:
                      "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}.png",
                  saveDir: "C:/MapDownload/Google Map/changanqu",
                  west: 108.6338137,
                  east: 109.2190777,
                  north: 34.3060843,
                  south: 34.0499605));
              // Get.toNamed('/second?id=123');
            },
            child: const Text('start download'),
          ),
          Obx(() {
            return Container(
              child: Text(
                  "${controller.getData().value != null ? controller.getData().value!.toView() : "等待下载中"}"),
            );
          })
        ])));
  }
}
